<?php
include 'init.php';
include "./include/membersite_config.php";

if(!$fgmembersite->CheckLogin())
{
    $fgmembersite->RedirectToURL("index.php");
    exit;
}

if (!isset($_GET['album_id']) || empty($_GET['album_id']) || !isset($_GET['Eimage_id']) || 
    empty($_GET['Eimage_id']) || album_check($_GET['album_id']) === false) {
  header('Location: albums.php');
  exit();
}

include 'template/header.php';

$album_id = $_GET['album_id'];
$album_data = album_data($album_id, 'name', 'description');
$Eimage_id = $_GET['Eimage_id'];
$Eimage_keywords = image_data($album_id, $Eimage_id, 'image_keywords');

echo '<h3>', $album_data['name'], '</h3><p>', $album_data['description'], '</p>';

	$strongF = "<strong>";
  $strongB = "</strong>";

//$images = get_images($album_id);

if (isset($_POST['image_keys'])) {
  $image_keys = $_POST['image_keys'];
  //print_r = $image_keywords;
  
  $errors = array();
  
  if (empty($image_keys)) {
    $errors[] = ''.$strongF.'!!! keywords required !!!'.$strongB.'';
  } else {
      
      if (strlen($image_keys) > 70) {
        $errors[] = ''.$strongF.'!!! Sorry! You cannot tag too much keywords !!!'.$strongB.'';
     }
   }
  
  if (!empty($errors)) {
    foreach ($errors as $error) {
      echo $error, '<br />';
    }
  } 
   else {
    edit_image($album_id, $Eimage_id, $image_keys);
    header('Location: view_album_test.php?album_id='.$album_id);
    exit();
   }

}
?>



<form action="?album_id=<?php echo $album_id; ?>&Eimage_id=<?php echo $Eimage_id; ?>" method="post">
<p>Keywords: <br /><textarea name="image_keys" rows="3" cols="15" maxlength="255"><?php echo  $Eimage_keywords['image_keywords']; ?> </textarea></p>
	 <p><input type="submit" value="Edit" /></p>
</form>









<?php
include 'template/footer.php';
?>


